﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MINERP.DAL.CommonDAL
{
    /// <summary>
    /// ORDERINFO表的基础数据库访问表
    /// </summary>
    public class OrderInfoDAL:DALBase
    {
        public orderInfo GetEntityByBarCode(string barCode)
        {
            //DataEntites.Refresh(System.Data.Objects.RefreshMode.StoreWins, DataEntites.orderInfo);
            //orderInfo oi;
            //using (newSampleYPDBEntities Ds=new newSampleYPDBEntities ())
            //{
            //     oi=Ds.orderInfo.FirstOrDefault(p => p.OrderProductCode == barCode);
            //}
            //return oi;
            return DataEntites.orderInfo.FirstOrDefault(p => p.OrderProductCode == barCode);
        }
        public orderInfo_BK GetEntityByBarCodeBK(string barCode)
        {
            //DataEntites.Refresh(System.Data.Objects.RefreshMode.StoreWins, DataEntites.orderInfo);
            //orderInfo oi;
            //using (newSampleYPDBEntities Ds=new newSampleYPDBEntities ())
            //{
            //     oi=Ds.orderInfo.FirstOrDefault(p => p.OrderProductCode == barCode);
            //}
            //return oi;
            return DataEntites.orderInfo_BK.FirstOrDefault(p => p.OrderProductCode == barCode);
        }

        public orderInfo GetOneById(int orderProductId)
        {
            //DataEntites.Refresh(System.Data.Objects.RefreshMode.StoreWins, DataEntites.orderInfo);
            return DataEntites.orderInfo.FirstOrDefault(p => p.OrderProductId == orderProductId);

            //return DataEntites.orderInfo.Where(string.Format("it.OrderProductId={0}", orderProductId)).FirstOrDefault();
            //orderInfo oi;
            //using (newSampleYPDBEntities ds = new newSampleYPDBEntities())
            //{
            //    oi = ds.orderInfo.FirstOrDefault(p => p.OrderProductId == orderProductId);
            //}
            //return oi;

        }

        /// <summary>
        /// 根据orderinfo的ID得到对应的产品ID
        /// </summary>
        /// <param name="orderproductid"></param>
        /// <returns></returns>
        public int GetProductIdById(int orderproductid)
        {
            throw new NotImplementedException();
        }
    }
}
